<?php
function countCoord($arg) {
	$array = split(" ", $arg);
	if($arg == "") {
		return 0;
	}
	return count($array);
}

function display($args) {
	echo "<table><tr><th>WorkerID</th><th>People</th><th>Bikes</th><th>Cars</th><th>Angle</th><th>Weather</th><th>Season</th><th>Time of day</th></tr>";
	foreach ($args as $row) {
		// need to process the coordinate variables and output only number in table
		$people = $row['people'];
		$bikes = $row['bikes'];
		$cars = $row['cars'];
		$people_num = $row['people_num'];
		$bikes_num = $row['bikes_num'];
		$cars_num = $row['cars_num'];
		echo "<tr>";
		echo "<td>".$row['workerid']."</td><td onclick=\"draw('{$people}')\">".$people_num."</td><td onclick=\"draw('{$bikes}')\">".$bikes_num."</td><td onclick=\"draw('{$cars}')\">".$cars_num."</td><td>".$row['angle']."</td><td>".$row['weather']."</td><td>".$row['season']."</td><td>".$row['timeofday']."</td>";
		echo "</tr>";
	}
	echo "</table>";
}

$image = $_GET['image'];

$sqlserver = mysql_connect('localhost','wustl_inst', 'wustl_pass');
if ($sqlserver != NULL) {
	$userdb = mysql_select_db('amos', $sqlserver);
	$detailsquery = mysql_query("select * from HIT3 where img_name=\"".$image."\"", $sqlserver);
	$counter = 0;
	while($row = mysql_fetch_array($detailsquery, MYSQL_ASSOC)) {
		$image_details[$counter] = $row;
		$counter++;
	}
	display($image_details);
}

?>